﻿Ext.namespace('iOS.BaseView');

Ext.define('BaseListView', {
    extend : 'BaseView',

    statics: {
        BaseCls       : 'list-view',
        ListContainer : 'list-container',
        ListCls       : 'ios-list',
        ListContent   : 'list-content'
    },

    /*
     * 列表数据
     * 格式 {
           context : '',
           others  : *
       }
     */
    _listCfg: [],

    /*
     * 列表里的HTML结构,字符串形式的数组
     */
    _listHtml: [],

    _attachEventListener: function(){
        this.getElCacheByCls(this.self.ListCls).on('rangeclick', {scope : this}, this.clickHandler);
    },
    /*
     * 单击事件处理函数
     */
    clickHandler: function(){
    },

    _initInnerDom: function(){
        this._initListHtml();
        var listHtml = this._listHtml,
            sttc     = this.self,
            htmlData = [
            '<div style="width:100%;-webkit-box-flex:400;">',
                '<div class="',sttc.ListContainer,'">'
        ];
        for(var i = 0; i < listHtml.length; i++){
            htmlData.push(
                '<div class="',sttc.ListCls,'">',
                    listHtml[i],
                '</div>'
            );
        }
        htmlData.push(
                '</div>',
            '</div>'
        );
        var config   = {
            direction  : 'vertical',
            bounces    : 'vertical'
        };
        this.getElCache().append(htmlData.join(''));
        var $el      = this.getElCacheByCls(sttc.ListContainer);
        $.scrollView($el.get(0), config); 
    },

    /*
     * 初始化列表里面的HTML
     */
    _initListHtml: function(){

    }
});

iOS.BaseView.BaseListView = BaseListView;